﻿using System;
using System.Collections.Generic;
using Runtime.DesignPattern;
using UnityEngine.iOS;

namespace Plugins.FormicArch.MVVM
{
    public class ModelManager:GameSingleton<ModelManager>
    {
        Dictionary<Type,IModel> _models = new Dictionary<Type, IModel>();
        public static T Get<T>() where T : IModel, new()
        {
            return Inst._Get<T>();
        }
        private T _Get<T>() where T : IModel, new()
        {
            Type type = typeof(T);
            if (!_models.TryGetValue(type,out IModel model))
            {
                _models.Add(type,model = new T());
            }

            return (T)model;
        }

    }
}